import os
def getRoot():
    return os.path.dirname(__file__)

def getImage(imageName):
    return os.path.join(getRoot(), imageName)

def getIcon(imageName, opacity=None, as_pixmap=False):
    from PyQt4 import QtGui
    path =  os.path.join(getRoot(), imageName)
    pixmap = QtGui.QPixmap(path)
    if opacity:
        alpha = QtGui.QPixmap(pixmap.size().width(), pixmap.size().height())
        alpha.fill(QtGui.QColor(opacity,opacity,opacity))
        pixmap.setAlphaChannel(alpha)

    if as_pixmap:
        return pixmap
    else:
        return QtGui.QIcon(pixmap)

HELP_IMAGE       = '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x06bKGD\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\x00\x00\tpHYs\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07tIME\x07\xd9\x07\x0f\x01\'\x0fX\x1e\xee\xc2\x00\x00\x02\x9fIDAT8\xcbuS]H\x14Q\x18=3;\xce\xaa\xeb\x7f\xb4\xa6lD\x92\xa8\x15J\x86\xf4\xf7\x92\xf4\x10\x15F\x0fe\xa8\x0fa\xe9Ci"\x89\x0f\t[\x99\x10F*\xb2i\ti\xd1\x8b\x95F\x18\xd2\x8f\xd4S\x99A\x88D\x98\x7f\xa5d\xda\x9a\xeb\x92\xa3\xbb3\xbb;\xf7\xdb\x99^\xd4v\xd5\x0e\x1c.\x1c\xeew\xbe\xf3}\xdc\xcb\xe9\xba\x8e\x81\xa1\t,\xe3\xc9\xd3W\xb1\x00\n\x01\xec\x06\xb0\x0b\x00\x0f\xe0\xf3\x12[O\x9f<\xe2D\x00\xb8@\x83\xf6\x8e\x97\xd7\x8cbHE\xf2\xb6-!\x1b\xe2\xa2\rq\xb1Q<\x00n^r\xf9\xff\xcc/\xfa\xc7\xbe\xfd`^\x9f\xda\x98\x9f{\xd4\x1ad\xd0?\xf8\x1d\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\xf9\x18\xb3\xd9\xc8\xf1\x86\xf5\xf7\xa1k\x90\xe6\x1c^\xb7$\xdd-))\xfc\xf7\x94\x9f\xf7|\x00\x0045\xdd\xaf\x11\x04\xa1\xdc\x14\x13+\x86ED\n\x82(\xf2\xcb\x0b\xf3\xb8]\xe4\x96$FL\xb5\x95\x96\x9e\xad\n\xfaL]\xaf{W\x9a\xdc\xb6\xb5Y\x00\x14\x018\x01 iI\x9e\x04\xd0\r\xa0\xf5b\xd9\xb9\x89\xc0P\x7f\x01\x82\x86x\xc5\xe4\x18\x17\xbb\x00\x00\x00\x00IEND\xaeB`\x82'

# Copyright 2008-2012 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios)
#
# This file is part of anim-studio-tools.
#
# anim-studio-tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# anim-studio-tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with anim-studio-tools.  If not, see <http://www.gnu.org/licenses/>.

